<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>确认订单</title>
	<link rel="stylesheet" href="__INDEX__/css/mui.min.css">
    <link rel="stylesheet" href="__INDEX__/css/style.css" />
    <link rel="stylesheet" href="__INDEX__/css/mall.css" />
</head>
<body>
	<nav class="mui-bar mui-bar-tab sppage_tab" style="height: 50px;">
	    <a class="mui-tab-item heji" style="width: 100%; text-align: left; padding-left: 3%;">合计：<em>¥{$total_money}</em></a>
	    <a class="mui-tab-item lijigoumai" style="width: 7rem;" id='to_pay'>
	        <span class="mui-tab-label">去付款</span>
	    </a>
	</nav>
	<div class="mui-content">	
		{volist name='order_items' id='goods_info'}
		<div class="querdd_topbox">
			<div class="left"><img src="{$goods_info['thumb']}"></div>
			<div class="right">
				<p class="name">{$goods_info['goods_name']}</p>
				<div class="pribox clearfix">
					<span class="pri">¥{$goods_info['price']}</span>
					×{$goods_info['nums']}
				</div>
			</div>
		</div>
		{/volist}
		<div class="maijly"><textarea placeholder="买家留言" id='message'></textarea></div>
	    <div class="biaodbox" style="width: 100%; padding-left: 3%; background: white;">
	    	<div class="type clearfix">
	    		<form class="mui-input-group" style="width: 100%;">
					<div class="mui-input-row mui-radio mui-left">
						<label>余额付款</label>
						<input name="pay_type" value="1" type="radio">
					</div>
					<div class="mui-input-row mui-radio mui-left">
						<label>微信支付</label>
						<input name="pay_type" value="2" type="radio" checked>
					</div>
				</form>
	    	</div>
	    	<div class="querdd_shdz">收货人：<em id="userName">{$member_address.consignee}</em><em style="margin-left: 80px;">联系电话：</em><em id="telNumber">{$member_address.con_mobile}</em></div>
	    	<div class="querdd_shdz">收货地址：<em id="address">{$member_address.address}</em>
	    	</div>
	    	<div class="querdd_shdz" style="height: 25px;">
	    	<a href="#" onclick="show_address()" id='my_address' style="float: right;color: #c1af4f;">修改收货地址></a>
	    	</div>
	    </div>
	    <ul class="querdd_zpribox">
	    	<li class="clearfix">
	    		<span class="left">商品金额</span>
	    		<span class="right pri">¥{$total_money}</span>
	    	</li>
	    	<li class="clearfix">
	    		<span class="left">运费</span>
	    		<span class="right">0</span>
	    	</li>
	    </ul>
	    {if $Think.session.user_info.is_rz!=1}
	    <button class="tixian_btn" ><a href="{:url('hyfw')}" style="color: #fff;">购买会员享受更多优惠~~立刻购买</a></button>
	    {/if}
	</div>
	<div id="callback"></div>
</body>
</body>
{include file="public/footer" /}
<script src="__INDEX__/js/mui.min.js"></script>

</html>
<script>
function show_address(){
	maddress();
}
	var to_pay = document.getElementById("to_pay");
	//监听点击事件
	to_pay.addEventListener("tap",function () {
		var add=$("#userName").text();
		if(add==""||add==null){
				layer.msg("请选择收货地址", {
				  icon: 2,
				  time: 1500 //2秒关闭（如果不配置，默认是3秒）
				}, function(){
					  maddress();
				}); 
			return;
		}
	  	$.ajax({
			url: "/index/payment/lc_wechat",
			data: {
				order_id		: "{$order_id}",
				order_type		: 3,
				message			: $('#message').val(),
				consignee		:$('#userName').text(),
				mobile			:$('#telNumber').text(),
				address			:$('#address').text(),
				body			: "用户购买商品",
				attach			: "用户购买商品"
			},
			type: "post",
			dataType: "jsonp",
			jsonp: 'callback',
			jsonpCallback: 'jsonpCallback',
			success: function(data) {
				callpay(data);
			}
		})
	});
	
function jsonpCallback(data) {
	$("#callback").append(data);
}
//调用微信JS api 支付
function jsApiCall(jsApiParameters) {
	WeixinJSBridge.invoke('getBrandWCPayRequest', jsApiParameters,
		function(res) {
			if(res.err_msg == "get_brand_wcpay_request:ok") {
				layer.msg("支付成功!", {
				  icon: 1,
				  time: 1000 //2秒关闭（如果不配置，默认是3秒）
				}, function(){
					 location.href = "/index/member/index";
				});
			} else {
				layer.msg("支付失败");
			}
		}
	);
}

function callpay(jsApiParameters) {
	console.log(jsApiParameters);
	if(typeof WeixinJSBridge == "undefined") {
		if(document.addEventListener) {
			document.addEventListener('WeixinJSBridgeReady', jsApiCall(jsApiParameters), false);
		} else if(document.attachEvent) {
			document.attachEvent('WeixinJSBridgeReady', jsApiCall(jsApiParameters));
			document.attachEvent('onWeixinJSBridgeReady', jsApiCall(jsApiParameters));
		}
	} else {
		jsApiCall(jsApiParameters);
	}
}
</script>